<%--
  Created by IntelliJ IDEA.
  User: Mr.Sun
  Date: 2019/11/15
  Time: 上午 10:06
  To change this template use File | Settings | File Templates.
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE HTML>
<html>
<head>
    <base>
    <title>信息管理</title>
    <meta charset="UTF-8">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <title>信息管理</title>
    <link rel="stylesheet" type="text/css" href="css/reset.css"/>
    <script src="js/jquery.js"></script>
    <script src="js/IM-index.js"></script>
    <link rel="stylesheet" type="text/css" href="css/IM-index.css"/>
    <script src="js/super.js"></script>
    <script type="text/javascript" src="js/sasdasd.js"></script>
    <script type="text/javascript" src="js/yeshu1.js"></script>
    <script type="text/javascript">
        window.onload = function () {
            gets();
            $.ajax({
                url: '${pageContext.request.contextPath}/SampleInfoController/selectAddress',
                type: 'post',
                dataType: "json",
                success: function (map) {
                    var obj = eval('(' + map + ')');
                    //console.log(obj);
                    var cityList = obj.cityList;
                    var provinceList = obj.provinceList;
                    var townList = obj.townList;
                    var shenId = document.getElementById("shen");
                    var shiId = document.getElementById("shi");
                    var xianId = document.getElementById("xian");

                    for (var i = 0; i < provinceList.length; i++) {
                        var opt = document.createElement("option");
                        opt.innerText = provinceList[i].name;
                        opt.setAttribute("value", provinceList[i].code)
                        shenId.appendChild(opt)
                    }
                    //给省份添加一个change事件
                    shenId.onchange = function () {
                        var procode = shenId.value;
                        //alert(procode)
                        //先清除原来的城市数据
                        shiId.innerHTML = "<option>选择市</option>";
                        xianId.innerHTML = "<option>选择区</option>";

                        for (var i in cityList) {
                            if (cityList[i].provincecode == procode) {
                                var opt = document.createElement("option");
                                opt.innerText = cityList[i].name;
                                opt.setAttribute("value", cityList[i].code);
                                shiId.appendChild(opt);
                            }
                        }
                    }
                    //给城市添加change事件，选择城市，获取区县
                    shiId.onchange = function () {
                        //获取城市ID
                        var cityCode = shiId.value;
                        //alert(cityCode)
                        //先清除原来的城市数据
                        xianId.innerHTML = "<option>选择区</option>";
                        //根据城市ID获取区县列表
                        for (var i in townList) {
                            if (townList[i].citycode == cityCode) {
                                var opt = document.createElement("option");
                                opt.innerText = townList[i].name;
                                opt.setAttribute("value", townList[i].code);
                                xianId.appendChild(opt);
                            }
                        }
                    }
                }
            })
        }

    </script>
    <script type="text/javascript">

        $(function () {
            $.ajax({
                url: '${pageContext.request.contextPath}/findSampleToxinInfo',
                type: 'post',
                dataType: "json",
                success: function (sampleToxinInfoList) {
                    var obj = JSON.parse(sampleToxinInfoList);
                    //console.log(obj);
                    var toxin_type = document.getElementById("toxin_type");
                    for (var i = 0; i < obj.length; i++) {
                        var opt = document.createElement("option");
                        opt.innerText = obj[i].toxinType;
                        opt.setAttribute("value", obj[i].id)
                        toxin_type.appendChild(opt)
                    }
                }
            })
        })
    </script>
    <%--查询农作物--%>
    <script type="text/javascript">
        $(function () {
            $.ajax({
                url: '${pageContext.request.contextPath}/findCropCpeciesLIst',
                type: 'post',
                dataType: "json",
                success: function (cropCpeciesLIst) {
                    var obj = JSON.parse(cropCpeciesLIst);
                    var crop_species = document.getElementById("crop_species");
                    for (var i = 0; i < obj.length; i++) {
                        var opt = document.createElement("option");
                        opt.innerText = obj[i].cropSpecies;
                        opt.setAttribute("value", obj[i].id)
                        crop_species.appendChild(opt)
                    }
                }
            })
        })
    </script>
    <%--批量删除--%>
    <script type="text/javascript">
        $(function () {
            $('#delete').click(function(){
                var ids = document.getElementsByName("checkOnediv");
                check_val = [];
                for(k in ids){
                    if(ids[k].checked)
                        check_val.push(ids[k].value);
                }
                $.ajax({
                    url:'/deleteSampleByIds',
                    type:'post',
                    traditional: true,
                    data:{
                        ids : check_val,
                    },
                    dataType: 'json',
                    success: function(data){
                    if (data=true){
                        alert("删除成功")
                        window.location.href = "IM.jsp";
                    }},
                })
            })
        })

    </script>
    <script type="text/javascript">
    $("[name='checkOnediv']").click(function () {
        if ($(this).is(":checked")) {
            $("[name=ck]:checkbox").prop("checked", true);
        } else {
            $("[name=ck]:checkbox").prop("checked", false);
        }
    });
 </script>
    <style>
        html, body {
            height: 100%;
        }
    </style>
</head>

<body>
<a name="top"></a>
<div class="contaner">
    <div class="im-content">
        <div class="im-heade">
            <div class="imhead-title">当前页面：<a>信息管理</a></div>
            <div class="imhead-select">
                <ul>

                    <li class="bh" id="sampleId111">
                        <lable>样品编号</lable>
                        <input maxlength="15" onkeyup="this.value=this.value.replace(/\s+/g,'')" id="sample_id"
                               name="sampleId" type="text">
                    </li>

                    <li class="wrl mright">
                        <lable>污染率</lable>
                        <select id="wuranluv" name="wuranlv">
                            <option value="">请选择</option>
                            <option name="0-20" value="0-20">0~20%</option>
                            <option name="20-40" value="20-40">20%~40%</option>
                            <option name="40-60" value="40-60">40%~60%</option>
                            <option name="60-80" value="60-80">60%~80%</option>
                            <option name="80-100" value="80-100">80%~100%</option>
                        </select>
                    </li>

                    <li class="time">
                        <lable>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;时间</lable>
                        <input id="qaz" value="" type="hidden">
                        <select name="year" id="year" class="year">
                            <option value="0">请选择</option>
                            <option value="1950">1950</option>

                        </select>
                        <span> &nbsp;年</span>
                        <select name="month" id="month" class="month">
                            <option value="0">请选择</option>
                        </select>
                        <span> &nbsp;月 </span>
                        <select name="day" id="day" class="day">
                            <option value="0">请选择</option>
                        </select>
                        <span>&nbsp; 日</span></li>
                    <li class="w mright yu">
                        <lable>主要污染菌种类</lable>
                        <select name="toxin_type" class="mainSpecies" id="toxin_type">
                            <option value="">请选择</option>
                        </select>
                    </li>
                    <li class="w mright yu">
                        <lable>农作物种类</lable>
                        <select name="crop_species" class="nzw_spacies" id="crop_species">
                            <option value="">请选择</option>

                        </select>
                    </li>
                    <li class="place w">
                        <lable>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;地点</lable>
                        <input type="hidden" value="" id="shengs">
                        <input type="hidden" value="" id="shisss">
                        <input type="hidden" value="" id="xiansss">
                        <input type="hidden" value="123" id="wsx">
                        <select name="province" class="province" id="shen"
                                onchange="changeShen(this.value,'shen','shi','xian')">
                            <option value="">请选择</option>

                        </select>
                        <span> &nbsp;省</span>
                        <select name="city" class="city" id="shi" onchange="changeShi(this.value,'shen','shi','xian')">
                            <option value="0">请选择</option>
                        </select>
                        <span> &nbsp;市</span>
                        <select name="county" class="county" id="xian">
                            <option value="0">请选择</option>
                        </select>
                        <span> &nbsp;县</span></li>
                </ul>
                <div class="soso"><a href="javascript:if(confirm('确实要搜索吗?'))location " onclick="gets(1)">搜索</a></div>
            </div>
            <div class="oper">
                <ul>
                    <li class="btn-top"><a href="editIM-add.jsp" class="dt">新增单条</a>
                        <form class="form-b" action="/updateExcel" method="post" enctype="multipart/form-data"
                              id="excelForm">
                            <input type="file" name="file" class="file-info-b  file-info-b-1" accept=".xls">
                            <a class="xz-btn-b xz-btn-b-1">选择文件</a>
                            <input type="text" name="" id="" value="" class="vall vall-1" readonly>
                            <input class="submit-b" type="submit"  value="导入样品信息">
                        </form>
                        <a class="mb" href="/download">下载模板</a> <br>
                        <a class="pl" id="delete">批量删除</a>
                        <!-- 产毒菌株信息的导入 -->
                        <form class="form-b" action="/updateBacterialExcel" method="post"
                              enctype="multipart/form-data" id="excelForm1">
                            <input type="file" name="file" class="file-info-b junzhu-a" accept=".xls">
                            <a class="xz-btn-b junzhu-b">选择文件</a>
                            <input type="text" name="" id="flag" value="" class="vall vall-c" readonly>
                            <input class="submit-b submit-c" type="submit" value="导入菌株信息">
                        </form>
                        <a href="/export" class="dc">信息导出</a></li>
                </ul>
            </div>
        </div>
        <div class="im-table">
            <table>
                <thead>
                <tr>
                    <th class="w1"><input type="checkbox" id="checkbox1" value="">
                        全选
                    </th>
                    <th class="w2">样品编号</th>
                    <th class="w3">地点</th>
                    <th class="w4">农产品加工类型</th>
                    <th class="w5">取样时间</th>
                    <th class="w6">录入时间</th>
                    <th class="w7">真菌污染率</th>
                    <th class="w8">主要毒素</th>
                    <th class="w9">操作</th>
                </tr>
                </thead>
                <tbody id="tbodya">
                <input type="hidden" type="text" id = "sadasdas" value="1">
                <input type="hidden" type="text" id = "abde" value="">
             <%--   <c:forEach items="${sampleInfoList}" var="list">
                    <tr>
                        <td><input class="testyangpin" value="754" type="checkbox"></td>
                        <td class="ybbh">${list.sampleId}</td>
                        <td>${list.city}</td>
                        <td>${list.cropCategoryId}</td>
                        <td><fmt:formatDate pattern="yyyy-MM-dd" type="date" value="${list.createTime}"/></td>
                        <td><fmt:formatDate pattern="yyyy-MM-dd" type="date" value="${list.inputTime}"/></td>
                        <td>${list.pollutionRate}</td>
                        <td>${list.sampleToxinInfo[0].toxinType}</td>
                        <td><a href="">编辑</a> |<a onclick="huoquid()">删除</a>
                        </td>
                    </tr>
                </c:forEach>--%>
                </tbody>
            </table>
        </div>
        <div class="page"></div>
    </div>
</div>
<!-- <link rel="stylesheet" type="text/css" href="../css/style.css"> -->
<link type="text/css" rel="stylesheet" href="css/paging.css">
<style type="text/css">
    .color a {
        padding: 5px;
        color: #4c4743;
        /* font-size: 20px; */
    }

    .color a:hover {
        color: #ed6c44;
    }

    /* .color2 {
        float: right;
        color: #4c4743;
        font-size: 20px;
        border: 1px black hidden;
    } */

    .color {
        /* 	float: right; */
        border: 1px black hidden;
        width: 100%;
        text-align: center;
    }

    #checkOne {
        color: #000;
        font-size: 20px;
    }

    #checkOnediv {
        color: #ed6c44;

    }

    /* #h1 {
        color: #4c4743;
    } */
</style>
<div class="im-page" id="impage">
        <ul id="pagediv" class="ul_page">
        </ul>
    <ul>
        <li class="im-indexpage"><a id='first'>首页</a></li>
        <li class="im-nextpage"><a id='before' >上一页</a></li>
        <li><a>第<span id="pnum"></span>页</a></li>
        <li>&nbsp;&nbsp;&nbsp;</li>
        <li><a>共<span id="ptotal"></span>页</a></li>
        <li class="im-nextpage"><a id='next' >下一页</a></li>
        <li class="im-indexpage"><a id='last'>尾页</a></li>
    </ul>
</div>
<script type="text/javascript" src="js/jquery1.11.3-jquery.min.js"></script>
<script type="text/javascript" src="js/browsing.js"></script>
<script type="text/javascript" src="js/linkage4.js"></script>
<script type="text/javascript">

    function doExport() {
        var ex = "";
        $.each($('input:checkbox:checked'), function () {
            if ($(this).val() != '') {
                ex = ex + ($(this).val() + ",");
            }
        });
        if (ex != '') {
            window.location = "rest/excel/message_export?ex=" + ex;
        } else {
            alert("请先勾选数据!");
        }
    }

    function nameCheck() {
        var img1 = $("input:file").val();
        if (img1 == '') {
            alert("请选择文件！");
            return false;
        }
        var img = $("input:file").val().split("\\");
        var imgName = img[img.length - 1];
        var imgshuzu = imgName.split(".");
        var imgleixing = imgshuzu[imgshuzu.length - 1];
        if (imgleixing == "xlsx") {
            $("#excelForm").submit();
        } else {
            alert("上传文件格式不正确，请上传2007版本的excel文档");
            return false;
        }
    }

    function nameCheck1() {
        var img1 = $("#flag").val();
        if (img1 == '') {
            alert("请选择文件！");
            return false;
        }
        var img = $("#flag").val().split("\\");
        var imgName = img[img.length - 1];
        var imgshuzu = imgName.split(".");
        var imgleixing = imgshuzu[imgshuzu.length - 1];
        if (imgleixing == "xlsx") {
            $("#excelForm1").submit();
        } else {
            alert("上传文件格式不正确，请上传2007版本的excel文档");
            return false;
        }
    }

    function testyangpin() {

        var msg = "您真的确定要删除吗？";
        if (confirm(msg) == true) {
            var urlss = "";
            var ss = $(".testyangpin");
            for (var i = 0; i < ss.length; i++) {
                if (ss[i].checked) {
                    urlss = urlss + ss[i].value + ",";
                }

            }
            if (urlss == "") {
                alert("请选择要删除的信息");
                return false;
            } else {
                location.href = "<%%>/rest/deletelists?urlss=" + urlss + "";
                return true;
            }


        } else {
            return false;
        }

    }

    function searchAll() {

        var sample_id = $("#sample_id").val();
        var pollution_rate = $("#wuranluv").val();

        var toxin_type = $("#toxin_type").val();
        var crop_species = $("#crop_species").val()
        ;

        var year = $("#year").val();


        var month = $("#month").val();
        if (month < 10) {
            month = "0" + month;
        } else if (month == "请选择") {
            month = "";
        }
        var day = $("#day").val();
        if (day < 10) {
            day = "0" + day;
        } else if (day == "请选择") {
            day = "";
        }
        var sampling_time = year.replace(/\s/g, "") + "-" + month.replace(/\s/g, "") + "-" + day.replace(/\s/g, "");
        var province = $("#shen option:selected").text();
        if (province == "请选择") {
            province = "";
        }
        var city = $("#shi option:selected").text();
        if (city == "请选择") {
            city = "";
        }
        var county = $("#xian option:selected").text();
        if (county == "请选择") {
            county = "";
        }

       // console.log(sample_id, pollution_rate, toxin_type, crop_species, sampling_time, province, city, county)
        location.href = "<%%>/rest/tolistim?param1=" + sample_id + "&param2=" + pollution_rate + "&param3=" + toxin_type + "&param4=" + crop_species + "&param5=" + sampling_time + "&param6=" + province + "&param7=" + city + "&param8=" + county;
    }
</script>
</body>
</html>
